<link rel="stylesheet" href="/Public/assets/layui/css/layui.css">
<link rel="stylesheet" href="/Public/style/eleTree.css">
<style>
    .layui-fixbar {
        display: none;
    }
    
    table {
        width: 100%;
        empty-cells: show;
        background-color: transparent;
        border-collapse: collapse;
        border-spacing: 0;
    }
    
    .table td {
        text-align: left;
    }
    
    .table th,
    .table td {
        padding: 8px;
        line-height: 20px;
    }
    
    ol>li>ol,
    ol>li>ul,
    ul>li>ol,
    ul>li>ul {
        margin: 0;
    }
    
    .va-t {
        vertical-align: top!important;
        min-height: 610px;
    }
    
    #tree-menu {
        display: none;
        position: absolute;
        z-index: 1000000;
        margin: 0;
        padding: 2px;
        background: #f5f5f5;
        border: 1px solid #979797;
        /* box-shadow: 2px 2px 2px #999; */
    }
    
    #tree-menu li>a {
        display: block;
        padding: 0 1em;
        text-decoration: none;
        width: auto;
        color: #000;
        white-space: nowrap;
        line-height: 2.4em;
        text-shadow: 1px 1px 0 #fff;
        border-radius: 1px;
    }
    
    .infoname {
        display: inline-block;
        color: red;
    }
    /******/
    
    .tips {
        font-weight: 600;
    }
    
    .layui-table-page {
        height: 45px;
    }
</style>
<div class="widget-head" style="margin-top:0;">
    <div class="widget-title">视频管理</div>
</div>
<!-- <div style="padding:10px;background:#f8f8f8;margin-bottom:10px;">
    <form class="layui-form" id="change_id" action="{:U('index')}" method="get">
        <div class="layui-form-item" style="margin-bottom:0;">
            <label class="layui-form-label" style="padding: 9px 0px;">文章分类：</label>
            <div class="layui-input-inline">
                <select name="pid" id="pid" lay-filter="pid" lay-verify="required" lay-search>
                    <option value="0" <if condition="$_GET['pid'] eq 0">selected</if>>请选择文章分类</option>
                    {$select_categorys}
                </select>

            </div>
            <a href="javascript:think_open('/admin/content/add','文章列表',['90%','90%'],1);" class="layui-btn layui-btn-normal"><i class="layui-icon"></i> 管理文章分类</a>
            <if condition="$_GET['pid']">
                <p style="line-height:38px;color:red">当前菜单ID：<b>{$_GET['pid']}</b></p>
            </if>

        </div>
    </form>
</div> -->

<div class="layui-container" style="width:100%;margin-top:20px;">
    <div class="layui-clear">
        <a class="layui-btn fl add" href="javascript:;"> 添加</a>
        <a class="layui-btn layui-btn-danger think-btn" data-type="del" data-url="{:U('del_content')}">删除</a>
        <form method="GET" action="{:U('index')}" class="fr layui-form" style="width:400px;" οnsubmit="return false;">
            <!-- <input type="hidden" name="pid" value="{$_GET['pid']}"> -->
            <div class="layui-input-inline fl" style="width:100px;">
                <php>$types = ['title'=>'文章标题'];</php>
                <select name="searchtype">
                    <foreach name="types" item="vo" key="k">
                        <option value="{$k}" <if condition="$_GET['searchtype'] eq $k">selected</if>>{$vo}</option>
                    </foreach>
                </select>
            </div>
            <div class="layui-input-inline fr" style="width:300px;">
                <button class="layui-btn fr" lay-submit>搜索</button>
                <input type="text" class="layui-input fr" style="width:230px;" name="keywords" placeholder="请输入关键词" value="{$_GET['keywords']}">
            </div>
            <php>
                $condition = $_GET['searchtype'] && $_GET['keywords'] ? "/searchtype/".$_GET['searchtype']."/keywords/".$_GET['keywords'] : '';
            </php>
            <script>
                var condition = '{$condition}';
            </script>
        </form>
    </div>
    <table id="list"></table>
    <!--  -->
    <script type="text/html" id="barDemo">
        <div class="layui-btn-group action-btn">
            <a class="layui-btn layui-btn-xs" onclick="think_open('/admin/content/edit_video/id/{{d.id}}','修改',['80%','80%'],0)">编辑</a>
            <a class="layui-btn layui-btn-danger layui-btn-xs mini_del" data-url="/admin/content/del_video/ids/{{d.id}}">删除</a>
        </div>
    </script>

    <!-- <script type="text/html" id="statusTpl">
        {{# if(d.status == 1){ }} <span class="layui-badge layui-bg-green">发布</span>{{# }else if(d.status == 0){ }}<span class="layui-badge">不发布</span>{{# } }}
    </script> -->

</div>

<script src="/Public/modules/eleTree.js" charset="utf-8"></script>
<script>
    layui.use(['jquery', 'form', 'miniweb', 'think'], function() {
        var form = layui.form,
            $ = layui.jquery,
            think = layui.think;

        // var id = $('#change_id').val();

        // form.on('select(pid)', function(data) {
        //     if (data.value != id) {
        //         $('#change_id').submit();
        //     }
        // });


    });
    mini_callback();
    //提供给iframe回调的函数
    function mini_callback() {
        layui.use(['jquery', 'eleTree', 'layer', 'form', 'laytpl', 'think'], function() {
            var $ = layui.jquery,
                eleTree = layui.eleTree,
                layer = layui.layer,
                form = layui.form,
                laytpl = layui.laytpl,
                think = layui.think;
            // layui.knowledge.loadTreeData();

            // var pid = $('#pid').val();
            // console.log(pid);

            $('.add').attr('onclick', "think_open('/admin/content/edit_video','添加',['80%','80%'],0)");

            think.render({
                elem: '#list',
                // url: '/api/content/getcontdata?pid=' + pid,
                url: '/api/content/get_video_data' + condition,
                page: true,
                cols: [
                    [ //表头
                        {
                            type: 'checkbox',
                            // fixed: 'left'
                        }, {
                            field: 'id',
                            title: 'ID',
                            sort: true,
                            width: 80,
                        }, {
                            field: 'title',
                            title: '视频标题'
                        }, {
                            field: 'url',
                            title: '视频地址'
                        }, {
                            field: 'author',
                            title: '作者'
                        }, {
                            field: 'create_time',
                            title: '创建时间',
                            sort: true,
                            width: 180,
                            templet: function(d) {
                                return think_time(d.update_time, 'Y-m-d H:i:s'); //think_time()是think.js里面的方法
                            }
                        }, {
                            title: '操作',
                            width: 180,
                            align: 'center',
                            toolbar: '#barDemo'
                        }
                    ]
                ]
            }, '{$_GET["searchtype"]}', '{$_GET["keywords"]}');

        });
    }
</script>